<?php

namespace App\Http\Controllers;

use App\Common\Constant\Status;
use Illuminate\Http\Request;

class BaseController extends Controller
{

    /**
     * 操作失败返回
     */
    protected function renderFail($code = Status::FAIL, $message = null)
    {
        if ($message === null){
            $message = (String)status($code);
        }
        return redirect(route('503'))->with('errorCode', $code)->with('errorMessage', $message);
    }

    /**
     * 异常错误返回
     */
    protected function renderError($code = Status::ERROR, $message = null)
    {
        if ($message === null){
            $message = (String)status($code);
        }
        return redirect(route('404'))->with('errorCode', $code)->with('errorMessage', $message);
    }
}
